/**
 * Copyright (c) 2022 Raspberry Pi (Trading) Ltd.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include "stdio.h"
#include "pico/stdlib.h"
#include "pico/multicore.h"
#include <rtthread.h>
#include <rtdevice.h>

void isr_systick(void)
{
	/* enter interrupt */
#ifndef RT_USING_SMP
	rt_interrupt_enter();
#endif

	rt_tick_increase();

	/* leave interrupt */
#ifndef RT_USING_SMP
	rt_interrupt_leave();
#endif
}

static void pico_set_led(bool led_on)
{

	gpio_put(PICO_DEFAULT_LED_PIN, led_on);
}

// Initialise led
static void pico_init_led(void)
{
	gpio_init(PICO_DEFAULT_LED_PIN);
	gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
}

void blink_task(__unused void *params)
{
	bool on = false;
	printf("blink_task starts\n");
	pico_init_led();
	while (true)
	{

		pico_set_led(on);
		on = !on;

		rt_thread_mdelay(1000);
	}
}

void main_task(__unused void *params)
{
}

// #include <rtthread.h>
// #include <rtdevice.h>

#define LED_PIN 25

void main1()
{
	bool on = false;
	pico_init_led();
	while (true)
	{

		pico_set_led(on);
		on = !on;

		rt_thread_mdelay(1000);
	}
}
void main(void)
{
	// stdio_init_all();

	// rt_kprintf("Hello, RT-Thread!\n");

	// rt_pin_mode(LED_PIN, PIN_MODE_OUTPUT);
	 main1();
}
